var addBtn = document.querySelector('#btn-add');
const inputname = document.querySelector('#inputName'),
      inputprice = document.querySelector('#inputPrice'),
      inputnum = document.querySelector('#inputNum'),
      msgWrap = document.querySelector('#msgWrap');
utils.on(addBtn,"click",function(){
    const name = inputname.value,
          price = inputprice.value,
          num = inputnum.value;
    utils.fetch("./api/shop/add.php",{name,price,num}).then(resp => {
        console.log(resp);
        msgWrap.innerHTML = resp.body.msg;
        if(resp.code === 200){
            msgWrap.classList.add('text-success');
            setTimeout(() => {
                $('#addModal').modal('hide')
                select();
            },2000)
        }else{
            msgWrap.classList.add('text-danger');
            setTimeout(() => {
                msgWrap.innerHTML = '';
                msgWrap.className = 'text-center';
            },2000)
        }
        
    })
})
$('#addModal').on('hidden.bs.modal', function (e) {
    inputname.value = '';
    inputprice.value = '';
    inputnum.value = '';
  })